//index.js
//获取应用实例
const app = getApp()
const api = require('../../utils/api.js');
Page({
	data: {
		statusImgSrc: "",
		statusName:"",
		customer:{},
	},
	//事件处理函数
	logout: function() {
		wx.navigateTo({
			url: '../login/login'
		})
	},
	makeCall:function(){
		wx.makePhoneCall({
		  phoneNumber: this.data.linkerPhone //仅为示例，并非真实的电话号码
		})
	},
	toLink:function(){
		wx.navigateTo({
			url: '../link/link'
		})
	},
	toMap:function(){
		wx.navigateTo({
			url: '../map/map'
		})
	},
	toInfo:function(){
		wx.navigateTo({
			url: '../info/info'
		})
	},
	toBank:function(){
		wx.navigateTo({
			url: '../bank/bank'
		})
	},
	toShopImg:function(){
		wx.navigateTo({
			url: '../shopImg/shopImg'
		})
	},
	toActivity:function(){
		wx.navigateTo({
			url: '../activity/list'
		})
	},
	toContract:function(){
		wx.navigateTo({
			url: '../contract/contract'
		})
	},
	toQrCode:function(){
		wx.navigateTo({
			url: '../qrCode/qrCode'
		})
	},
	onLoad: function() {
		let _this = this;
		wx.getStorage({
		 	key: 'customerId',
		  	success: function(res) {
		      	_this.getCustomerInfo(res.data);
		  	} 
		})
		
	},
	//查询商户详情
	getCustomerInfo:function(id){
		let _this = this;
		api.getCustomerInfo({
			data: {
				id:id
			},
			success: function(res) {
				if(res.data.code == 0) {
					let obj = res.data.obj;
					console.log(obj);
					if(obj.status == 0){
						_this.setData({
							statusName:"待完善",
							statusImgSrc:"../../images/perfected.png"
						})
					}else if(obj.status == 1){
						_this.setData({
							statusName:"待审核",
							statusImgSrc:"../../images/info.png"
						})
					}else if(obj.status == 2){
						_this.setData({
							statusName:"审核通过",
							statusImgSrc:"../../images/success.png"
						})
					}else if(obj.status == 3){
						_this.setData({
							statusName:"审核驳回",
							statusImgSrc:"../../images/error.png"
						})
					}
					wx.setStorage({
					  	key:"customerInfo",
					  	data:obj
					})
					_this.setData({
						customer: obj,
					})
				}
			},
		});
	},
})